Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stable_pool: math #414

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

stable_pool: math #414

wants to merge 9 commits into from

Conversation

gangov
Copy link
Collaborator

@gangov gangov commented Jan 8, 2025

  • updated scale_value: now uses the env parameter and U256 type for handling larger numbers, preventing overflow issues.
  • changed compute_d: refactored to use the U256 type for precise multiplication and division.
  • changed Newton's method in compute_d: should be achieving the same approximation of D using an optimized approach.
  • changed calc_y: uses a reordered formula and iterative (Newton-like) methods for the swap amount calculations.
  • fixed overflow in calc_y: the complex arithmetic operations are broken into smaller, manageable steps to prevent overflow errors and products of numbers that don't fit in U256 (eg. 200000000000000000000000^3 x 100000000000).

@gangov gangov self-assigned this Jan 8, 2025
@gangov gangov requested a review from ueco-jb January 8, 2025 15:29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good tests. 👍

Copy link
Member

@ueco-jb ueco-jb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include tests that swaps more then 0.5 of a token.

@gangov gangov force-pushed the kalo/stable_pool-math branch from 1004f11 to 7833db9 Compare January 16, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants